import * as constants from './constants'
import axios from 'axios'

export const addNumber = (num) => ({
  type: constants.ADD_NUMBER,
  num
})
export const subNumber = (num) => ({
  type: constants.SUB_NUMBER,
  num
})

export const bannerAction = (bannes) => ({
  type: constants.CHANGE_BANNERS,
  bannes
})
export const changeBanners = (banners) => {
  // 这个函数会被制动执行
  function foo(dispatch) {
    // 执行异步操作
    axios.get('http://123.207.32.32:8000/home/multidata').then(res => {
      console.log(res.data.data.banner.list)
      dispatch(bannerAction(res.data.data.banner.list))
    })
  }
  return foo
}